home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
ole
/
ole2bm
/
ole2bm.frm
< prev
next >
Wrap
Text File
|
1994-05-06
|
6KB
|
196 lines
VERSION 2.00
Begin Form frmDemo
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "OLE 2.0 To Bitmap Demo"
ClientHeight = 3915
ClientLeft = 1095
ClientTop = 1470
ClientWidth = 6315
Height = 4320
Left = 1035
MaxButton = 0 'False
ScaleHeight = 3915
ScaleWidth = 6315
Top = 1125
Width = 6435
Begin CommandButton cmdEdit
Caption = "&Edit Picture Box Bitmap"
Default = -1 'True
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 435
Left = 0
TabIndex = 0
Top = 3480
Width = 3195
End
Begin OLE olePbrush
AutoActivate = 0 'Manual
Class = "PBrush"
fFFHk = -1 'True
Height = 2955
Left = 3240
OleObjectBlob = OLE2BM.FRX:0000
OLETypeAllowed = 1 'Embedded
TabIndex = 3
Top = 120
Width = 2955
End
Begin PictureBox picBitmap
AutoRedraw = -1 'True
DrawStyle = 6 'Inside Solid
DrawWidth = 12
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 30
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 2955
Left = 120
ScaleHeight = 195
ScaleMode = 3 'Pixel
ScaleWidth = 195
TabIndex = 2
Top = 120
Width = 2955
End
Begin CommandButton cmdQuit
Cancel = -1 'True
Caption = "&Quit"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 435
Left = 3180
TabIndex = 1
Top = 3480
Width = 3135
End
Begin Label lblImage
BackStyle = 0 'Transparent
Caption = "OLE 2.0 PaintBrush Object"
Height = 315
Index = 1
Left = 3240
TabIndex = 5
Top = 3120
Width = 2955
End
Begin Label lblImage
BackStyle = 0 'Transparent
Caption = "VB Picture Box Bitmap"
Height = 315
Index = 0
Left = 120
TabIndex = 4
Top = 3120
Width = 2955
End
End
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' OLE2BM.FRM
'____________________________________________________________________________
Option Explicit
DefInt A-Z
Dim PictureStale
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Embed bitmap in OLE 2.0 object and open PaintBrush to edit it.
'____________________________________________________________________________
Sub cmdEdit_Click ()
Pic2Ole picBitmap, olePbrush
PictureStale = True
olePbrush.Action = OLE_ACTIVATE
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Quit the program.
'____________________________________________________________________________
Sub cmdQuit_Click ()
End
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Make sure the picture box gets painted on loading.
'____________________________________________________________________________
Sub Form_Paint ()
picBitmap_Paint
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Embed bitmap in OLE 2.0 object and open PaintBrush to edit it.
'____________________________________________________________________________
Sub olePbrush_Click ()
cmdEdit = True
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Update picture box if PaintBrush object data has changed.
'____________________________________________________________________________
Sub olePbrush_Updated (Code As Integer)
If PictureStale And Code = OLE_CHANGED Then
Ole2Pic picBitmap, olePbrush
PictureStale = False ' Prevent cascading Updated event
End If
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Edit the source bitmap.
'____________________________________________________________________________
Sub picBitmap_DblClick ()
cmdEdit = True
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Draw the source bitmap on loading.
'____________________________________________________________________________
Sub picBitmap_Paint ()
Static called
Dim h, w, xc, xl, xr, yb, yc, yt
Dim red As Long
Const msg$ = "KLUDGE"
If Not called Then ' Paint just once to preserve edits
xl = 0
xr = picBitmap.ScaleWidth
xc = xr \ 2
yt = 0
yb = picBitmap.ScaleHeight
yc = yb \ 2
w = picBitmap.TextWidth(msg$)
h = picBitmap.TextHeight(msg$)
red = QBColor(4)
picBitmap.CurrentX = (xr - w) \ 2
picBitmap.CurrentY = (yb - h) \ 2
picBitmap.Print msg$
picBitmap.Circle (xc, yc), xc, red
picBitmap.Line (xr, yt)-(xl, yb), red
picBitmap.Refresh
called = True
End If
End Sub